/**
 * 坦克爆炸的对象
 * x,y
 * 坦克在哪里死的爆炸就在哪里产生
 */
class Boom {
    constructor(x, y) {
        this.x = x;
        this.y = y;
        //图片，这里的图片不可能是1张，它是7张
        this.imgs = imgList.slice(17, 24).reverse();
        this.width = this.imgs[0].width / 3;
        this.height = this.imgs[0].height / 3;
        //定义一个图片的索引，循环绘制图片
        this.imgIndex = 0;
    }
    /**
     * 绘制自己 
     * @param {CanvasRenderingContext2D} ctx 
     */
    draw(ctx) {
        ctx.drawImage(this.imgs[parseInt(this.imgIndex)], this.x, this.y, this.width, this.height);
        this.imgIndex += 0.2;
        if (this.imgIndex > this.imgs.length - 1) {
            //就说明图片画完成,我们应该上面移除这个爆炸的动画对象
            // this.imgIndex = 0;
            let index = boomList.indexOf(this);
            boomList.splice(index, 1);
        }
    }
}